# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
require 'lib/simple-json'

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  # protect_from_forgery # :secret => 'fd16bc5062db92e058dcacf8e850d480'
  
  protected
  def render_json(json, options={})
    text = options[:callback].blank? ? JsonBuilder.new.build(json) : "#{options[:callback]}(#{JsonBuilder.new.build(json)});"
    render({:content_type => :js, :text => text}.merge(options))
  end
  
end
